Ext.define('CDR.view.TariffCallRecord', {
	extend: 'Ext.Panel',
	alias: 'widget.tariff-call-record',
	id: 'x-cdr-tariff-call-record',
	title: 'Call Record',
	viewType: 0,
	tbar: ['->', {
		iconCls: 'icon-tab',
		enableToggle: true,
		toggleGroup:'change-view',
		name: 'tab-view'
	} ,'-' , {
		iconCls: 'icon-vertical',
		toggleGroup:'change-view',
		name: 'horizontal-view'
	}, '-' , {
		iconCls: 'icon-horizontal',
		toggleGroup:'change-view',
		name: 'vertical-view'
	}],
	layout: 'fit',
	border: false,
	initComponent: function(){
		var me = this;
		me.callParent(arguments);
		me.logStore = Ext.create('Ext.data.Store', {
			fields:[{name: 'parseData'}],
			pageSize: 50,
			buffered: true,
			purgePageCount: 0,
			proxy: {
	            type: 'memory'
	        }
		});
		me.callStore = Ext.create('Ext.data.Store', {
			model:'CDR.model.CallLogModel',
			pageSize: 50,
			buffered: true,
			purgePageCount: 0,
			proxy: {
	            type: 'memory'
	        }
		});
		//me.callStore.guaranteeRange(0,49);
		me.changeView(2);
	},
	
	changeView: function(viewType) {
		var me = this;
		me.viewType = viewType;
		me.removeAll();
		if(me.viewType == 0){
			me.add({
				xtype: 'tabpanel',
				tabPosition: 'bottom',
				layout: 'fit',
				activeTab: 1,
				border: false,
				items: [{
					xtype: 'tariff-amq-call-log',
					store: me.callStore,
					border: false,
					title: 'Call Record'
				}, {
					xtype: 'tariff-amq-console-log',
					store: me.logStore,
					border: false,
					title: 'Log Record'
				}]
			});
		} else if(me.viewType == 1){
			me.add({
				xtype: 'panel',
				border: false,
				layout: { 
					type:'border'
				},
				items: [{
					xtype: 'tariff-amq-call-log',
					region: 'center',
					store: me.callStore,
					border: false,
					title: 'Call Record'
				}, {
					xtype: 'tariff-amq-console-log',
					border: false,
					height: '50%',
					store: me.logStore,
					split: true,
					collapsible: true,
					region: 'south',
					title: 'Log Record'
				}]
			});
		} else if(me.viewType == 2){
			me.add({
				xtype: 'panel',
				border: false,
				layout: { 
					type:'border'
				},
				items: [{
					xtype: 'tariff-amq-call-log',
					region: 'center',
					border: false,
					store: me.callStore,
					title: 'Call Record'
				}, {
					xtype: 'tariff-amq-console-log',
					title: 'Log Record',
					border: false,
					store: me.logStore,
					width: '100%',
					split: true,
					collapsible: true,
					region: 'west',
				}]
			});
		}
	}
	
});